public class Main6 {
    public static void main(String[] args) {
        //6、设计一个接口Student,该接口描述的是本科生（StudentG)和硕士生（StudentM)的公共方法：
        // 设置姓名、学号，输出所有信息，判断学生是否优秀。
        // 在该接口的基础上实现两个类StudentG和StudentM。
        //StudentG属性：姓名，学号，是否过CET4,上学年综合测评成绩。
        // StudentG包含方法：构造方法，设置是否过CET4，设置上学年综合测评成绩，
        // 接口中定义的所有方法（本科生优秀的标准是过CET4，上学年综合测评成绩大于85分）。
        //StudentM属性：姓名，学号，是否过CET6,已发表文章篇数。
        // StudentM包含方法：构造方法，设置是否过CET6，设置发表文章篇数，
        // 接口中定义的所有方法（硕士生优秀的标准是过CET6，已发表文章篇数大于1）。
        //要求：（1）实现上述的接口和类；
        // （2）（在main函数内）实例化五个对象：三个本科生，两个硕士生（至少各有一个优秀）；
        // (3）用多态性来判断所实例化的五个学生是否优秀；
        // （4）输出优秀学生的所有属性信息
        // 。
        Student student = new StudentG("张三","1",false,85);
        Student student1 = new StudentG("李四","2",true,86);
        Student student2 = new StudentG("王五","3",false,85);
        Student student3 = new StudentM("刘六","4",false,0);
        Student student4 = new StudentM("琪七","5",true,2);

        Student[] students = {student,student1,student2,student3,student4};

        for (Student s : students){
            if(s.isExcellent()) {
                s.show();
            }
        }
    }
}

interface Student{
    public void setName(String name);
    public void setNum(String num);
    public void show();
    public boolean isExcellent();
}

class StudentG implements Student{
    String name;
    String num;
    boolean isPassCET4;
    double grade;
    public StudentG() {
    }

    public StudentG(String name, String num, boolean isPassCET4, double grade) {
        this.name = name;
        this.num = num;
        this.isPassCET4 = isPassCET4;
        this.grade = grade;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void setNum(String num) {
        this.num = num;
    }

    public void setPassCET4(boolean passCET4) {
        isPassCET4 = passCET4;
    }

    public void setGrade(double grade) {
        this.grade = grade;
    }

    @Override
    public void show() {
        System.out.println("StudentG{" +
                "name='" + name + '\'' +
                ", num='" + num + '\'' +
                ", isPassCET4=" + isPassCET4 +
                ", grade=" + grade +
                '}');
    }

    @Override
    public boolean isExcellent() {
        if (this.isPassCET4 && this.grade > 85){
            return true;
        }else {
            return false;
        }
    }
}

class StudentM implements Student{
    String name;
    String num;
    boolean isPassCET6;
    int paperNum;
    public StudentM() {
    }

    public StudentM(String name, String num, boolean isPassCET6, int paperNum) {
        this.name = name;
        this.num = num;
        this.isPassCET6 = isPassCET6;
        this.paperNum = paperNum;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void setNum(String num) {
        this.num = num;
    }

    public void setPassCET6(boolean passCET6) {
        isPassCET6 = passCET6;
    }

    public void setPaperNum(int paperNum) {
        this.paperNum = paperNum;
    }

    @Override
    public void show() {
        System.out.println("StudentM{" +
                "name='" + name + '\'' +
                ", num='" + num + '\'' +
                ", isPassCET6=" + isPassCET6 +
                ", paperNum=" + paperNum +
                '}');
    }

    @Override
    public boolean isExcellent() {
        if (this.isPassCET6 && this.paperNum > 1){
            return true;
        }else {
            return false;
        }
    }
}